{% if 'kube-master' in salt['grains.get']('roles', []) %}
{% set api_server = '127.0.0.1'  -%}
{% else %}
{% set api_server = salt['pillar.get']('kubernetes:lookup:kube-apiserver:PUBLIC_ADDRESS', '127.0.0.1')  -%}
{% endif %}
{% set api_ssl_port = salt['pillar.get']('kubernetes:lookup:kube-apiserver:apiserver_port', '6443') -%}
{% set api_server_url = 'https://' + api_server + ':' + api_ssl_port -%}

apiVersion: v1
clusters:
- cluster:
    certificate-authority: {{ pillar['ssl']['ca_file'] }}
    server: {{ api_server_url }}
  name: default-cluster
contexts:
- context:
    cluster: default-cluster
    user: {{ user }}
  name: default-system
current-context: default-system
kind: Config
preferences: {}
users:
- name: {{ user }}
  user:
    client-certificate: {{ client_certificate }}
    client-key: {{ client_key }}
